package com.example.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * @program: sms
 * @description:
 * @author: zhanghz001
 * @create: 2020-11-04 14:26
 **/
// @WebListener
public class ServletContextListenerDemo implements ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("servlet context init");
        sce.getServletContext().setAttribute("aaa", "aaa");
        sce.getServletContext().setAttribute("bbb", "bbb");
        sce.getServletContext().setAttribute("bbb", "ccc");
        sce.getServletContext().removeAttribute("bbb");
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("servlet context destroy");
    }
}
